{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport { useRef, useState, useEffect } from 'react';\n\n/**\n * Execute code before next frame but async\n */\nexport function useLayoutState(defaultState) {\n  var stateRef = useRef(defaultState);\n  var _useState = useState({}),\n    _useState2 = _slicedToArray(_useState, 2),\n    forceUpdate = _useState2[1];\n  var lastPromiseRef = useRef(null);\n  var updateBatchRef = useRef([]);\n  function setFrameState(updater) {\n    updateBatchRef.current.push(updater);\n    var promise = Promise.resolve();\n    lastPromiseRef.current = promise;\n    promise.then(function () {\n      if (lastPromiseRef.current === promise) {\n        var prevBatch = updateBatchRef.current;\n        var prevState = stateRef.current;\n        updateBatchRef.current = [];\n        prevBatch.forEach(function (batchUpdater) {\n          stateRef.current = batchUpdater(stateRef.current);\n        });\n        lastPromiseRef.current = null;\n        if (prevState !== stateRef.current) {\n          forceUpdate({});\n        }\n      }\n    });\n  }\n  useEffect(function () {\n    return function () {\n      lastPromiseRef.current = null;\n    };\n  }, []);\n  return [stateRef.current, setFrameState];\n}\n/** Lock frame, when frame pass reset the lock. */\n\nexport function useTimeoutLock(defaultState) {\n  var frameRef = useRef(defaultState || null);\n  var timeoutRef = useRef();\n  function cleanUp() {\n    window.clearTimeout(timeoutRef.current);\n  }\n  function setState(newState) {\n    frameRef.current = newState;\n    cleanUp();\n    timeoutRef.current = window.setTimeout(function () {\n      frameRef.current = null;\n      timeoutRef.current = undefined;\n    }, 100);\n  }\n  function getState() {\n    return frameRef.current;\n  }\n  useEffect(function () {\n    return cleanUp;\n  }, []);\n  return [setState, getState];\n}","map":{"version":3,"names":["_slicedToArray","useRef","useState","useEffect","useLayoutState","defaultState","stateRef","_useState","_useState2","forceUpdate","lastPromiseRef","updateBatchRef","setFrameState","updater","current","push","promise","Promise","resolve","then","prevBatch","prevState","forEach","batchUpdater","useTimeoutLock","frameRef","timeoutRef","cleanUp","window","clearTimeout","setState","newState","setTimeout","undefined","getState"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/rc-table/es/hooks/useFrame.js"],"sourcesContent":["import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport { useRef, useState, useEffect } from 'react';\n\n/**\n * Execute code before next frame but async\n */\nexport function useLayoutState(defaultState) {\n  var stateRef = useRef(defaultState);\n\n  var _useState = useState({}),\n      _useState2 = _slicedToArray(_useState, 2),\n      forceUpdate = _useState2[1];\n\n  var lastPromiseRef = useRef(null);\n  var updateBatchRef = useRef([]);\n\n  function setFrameState(updater) {\n    updateBatchRef.current.push(updater);\n    var promise = Promise.resolve();\n    lastPromiseRef.current = promise;\n    promise.then(function () {\n      if (lastPromiseRef.current === promise) {\n        var prevBatch = updateBatchRef.current;\n        var prevState = stateRef.current;\n        updateBatchRef.current = [];\n        prevBatch.forEach(function (batchUpdater) {\n          stateRef.current = batchUpdater(stateRef.current);\n        });\n        lastPromiseRef.current = null;\n\n        if (prevState !== stateRef.current) {\n          forceUpdate({});\n        }\n      }\n    });\n  }\n\n  useEffect(function () {\n    return function () {\n      lastPromiseRef.current = null;\n    };\n  }, []);\n  return [stateRef.current, setFrameState];\n}\n/** Lock frame, when frame pass reset the lock. */\n\nexport function useTimeoutLock(defaultState) {\n  var frameRef = useRef(defaultState || null);\n  var timeoutRef = useRef();\n\n  function cleanUp() {\n    window.clearTimeout(timeoutRef.current);\n  }\n\n  function setState(newState) {\n    frameRef.current = newState;\n    cleanUp();\n    timeoutRef.current = window.setTimeout(function () {\n      frameRef.current = null;\n      timeoutRef.current = undefined;\n    }, 100);\n  }\n\n  function getState() {\n    return frameRef.current;\n  }\n\n  useEffect(function () {\n    return cleanUp;\n  }, []);\n  return [setState, getState];\n}"],"mappings":"AAAA,OAAOA,cAAc,MAAM,0CAA0C;AACrE,SAASC,MAAM,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;;AAEnD;AACA;AACA;AACA,OAAO,SAASC,cAAc,CAACC,YAAY,EAAE;EAC3C,IAAIC,QAAQ,GAAGL,MAAM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